/**
 * @author LKQ
 * @date 2022/2/27 14:30
 * @description x0 / x1 / x2 / x3 .. / xn-1 分子为x0要使结果最大，那么括号必须将x0尽量扩充，则 x0 / (x1 / x2/ x3../xn-1) 将第二个数
 * 后面的数全部翻转到分子，变为 x0 * x2 * x3 * xn-1 / x1
 */
public class Solution {
    public static void main(String[] args) {
        Solution solution = new Solution();
        int[] nums = {1000, 100, 10, 2};
        solution.optimalDivision(nums);
    }
    public String optimalDivision(int[] nums) {
        int n = nums.length;
        if (n == 1) {
            return String.valueOf(nums[0]);
        }
        if (n == 2) {
            return nums[0] + "/" + nums[1];
        }
        StringBuffer sb = new StringBuffer();
        sb.append(nums[0]);
        sb.append("/(").append(nums[1]);
        for (int i = 2; i < n; i++) {
            sb.append("/").append(nums[i]);
        }
        sb.append(")");
        return sb.toString();
    }
}
